package com.licode.utils.unilite.result;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常方法拦截
 *
 * @author licode
 */
@RestControllerAdvice
public class UniExceptionHandler {
    @ExceptionHandler(Exception.class)
    public UniResult<Object> exceptionHandler(Exception e) {
        e.printStackTrace();
        return UniResult.fail(UniResultCode.SYSTEM_ERROR.code(),
                UniResultCode.SYSTEM_ERROR.message());
    }

    @ExceptionHandler(UniException.class)
    public UniResult<Object> uniExceptionHandler(UniException e) {
        e.printStackTrace();
        return UniResult.fail(e.getCode(), e.getMessage());
    }
}
